﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;

namespace Beat_em_Up.Scenes
{
    class Botao
    {
        Texture2D mouse_up;
        Texture2D mouse_over;
        //Texture2D? mouse_click;

        Rectangle posicao;

        //animacao

        bool is_mouse_over;
        bool is_mouse_click;

        public Botao(Texture2D mouse_up)//, Texture2D? _mouse_over, Texture2D? mouse_click)
        {
            this.mouse_up = mouse_up;

            posicao = new Rectangle();

            posicao.Width = mouse_up.Width;//LEVAR EM CONTA A ANIMACAO
            posicao.Height = mouse_up.Height;
            posicao.X = 100;//COLOCAR EM METODO SEPARADO
            posicao.Y = 100;

            is_mouse_over = false;
            is_mouse_click = false;

            //this.mouse_over = 
            //this.mouse_click = mouse_click;
        }

        public Botao(Texture2D mouse_up, Texture2D _mouse_over)
        {
            this.mouse_up = mouse_up;
            this.mouse_over = _mouse_over;

            posicao.Width = mouse_up.Width;//LEVAR EM CONTA A ANIMACAO
            posicao.Height = mouse_up.Height;
            posicao.X = 100;//COLOCAR EM METODO SEPARADO
            posicao.Y = 100;

            is_mouse_over = false;
            is_mouse_click = false;

            //this.mouse_click = mouse_click;
        }

        public void Update(GameTime gameTime, MouseState actualMouse)
        {
            if (posicao.Contains(actualMouse.X, actualMouse.Y))
            {
                is_mouse_over = true;

                if (actualMouse.LeftButton == ButtonState.Pressed)
                {
                    is_mouse_click = true;//TRABALHAR MELHOR A QUESTAO DO CLICK DO MOUSE
                }
            }
            else
            {
                is_mouse_click = false;
                is_mouse_over = false;
            }
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {

            
            spriteBatch.Draw(mouse_up, posicao, Color.White);
            
            if (is_mouse_over)
            {
                spriteBatch.Draw(mouse_over, posicao, Color.White);
            }

            //spriteBatch.Draw(mouse_up, Vector2.Zero, Color.White);

            //if (mouse_over != null)
            //{
            //    spriteBatch.Draw(mouse_over, posicao, Color.White);
            //}

            //if (mouse_click != null)
            //{
            //    spriteBatch.Draw(mouse_click, Vector2.Zero, Color.White);
            //}


        }

    }
}

